package com.cq.hd.member.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.member.api.dto.AdminUserPointsDetailPageDto;
import com.cq.hd.member.api.dto.UserPointsDetailPageDto;
import com.cq.hd.member.api.vo.AdminUserPointsDetailPageVo;
import com.cq.hd.member.api.vo.UserPointsDetailPageVo;
import com.cq.hd.member.mapper.TbUserPointsDetailMapper;
import com.cq.hd.member.po.TbUserPointsDetailPo;
import com.cq.hd.member.service.TbUserPointsDetailService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class TbUserPointsDetailServiceImpl extends ServiceImpl<TbUserPointsDetailMapper, TbUserPointsDetailPo> implements TbUserPointsDetailService {
    @Override
    public Page<UserPointsDetailPageVo> pageUserPointsDetail(UserPointsDetailPageDto userPointsDetailPageDto) {
        PageHelper.startPage(userPointsDetailPageDto.getPageNum(), userPointsDetailPageDto.getPageSize());
        List<UserPointsDetailPageVo> userPointsDetailPageVos = baseMapper.listUserPointsDetailByDto(userPointsDetailPageDto);
        PageInfo<UserPointsDetailPageVo> pageInfo = new PageInfo<>(userPointsDetailPageVos);
        return Page.newPageWithAllFields(pageInfo.getList(), pageInfo.getPageNum(), pageInfo.getPageSize(), pageInfo.getTotal(), pageInfo.getPages());

    }

    @Override
    public Page<AdminUserPointsDetailPageVo> adminPageUserPointsDetail(AdminUserPointsDetailPageDto adminUserPointsDetailPageDto) {
        PageHelper.startPage(adminUserPointsDetailPageDto.getPageNum(), adminUserPointsDetailPageDto.getPageSize());
        List<AdminUserPointsDetailPageVo> pageVos = baseMapper.listAdminUserPointsDetailByDto(adminUserPointsDetailPageDto);
        PageInfo<AdminUserPointsDetailPageVo> pageInfo = new PageInfo<>(pageVos);
        return Page.newPageWithAllFields(pageInfo.getList(), pageInfo.getPageNum(), pageInfo.getPageSize(), pageInfo.getTotal(), pageInfo.getPages());
    }
}
